import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import UserAdd from '@/views/UserAdd'
import Login from '@/views/Login'
import MyuserProfile from '@/views/MyuserProfile'
import MyseniorProfile from '@/views/MyseniorProfile'
import SeniorProfile from '@/views/SeniorProfile'
import Edit from '@/views/edit'
import Senior from '@/views/senior'
import Detail from '@/views/detail'
import Addexp from '@/views/addexp'
import Chat from '@/views/chat'
import Search from '@/views/search'
import ShowList from '@/views/showlist'
import store from '../store'
Vue.use(Router)

const router=new Router({
  routes: [
    {
      path: '/',
      name: 'Login',
      component: Login
    },
    {
      path: '/home',
      name: 'home',
      component:()=>import('@/views/home')
    },
    {
      path: '/users',
      name: 'Users',
      component:()=>import('@/views/users')
    },
    {
      path: '/useradd',
      name: 'Useradd',
      component: UserAdd
    },
    
    {
      path: '/hello',
      name: 'HelloWorld',
      component: HelloWorld
    },
    {
      path: '/myuserProfile',
      name: 'myuserProfile',
      component: MyuserProfile
    },
    {
      path: '/myseniorProfile',
      name: 'myseniorProfile',
      component: MyseniorProfile
    },
    {
      path: '/seniorProfile/:id',
      name: 'seniorProfile',
      component: SeniorProfile
    },
    {
      path: '/edit',
      name: 'Edit',
      component: Edit
    },
    {
      path: '/senior',
      name: 'Senior',
      component: Senior
    },
    {
      path: '/detail/:id',
      name: 'Detail',
      component: Detail
    },
    {
      path: '/addexp',
      name: 'Addexp',
      component: Addexp
    },
    {
      path: '/chat',
      name: 'Chat',
      component: Chat
    },
    {
      path: '/search',
      name: 'Search',
      component: Search
    },
    {
      path: '/showlist',
      name: 'ShowList',
      component: ShowList
    },
  ]
})

// router.beforeEach((to,from,next)=>{
//   if(to.name !=='Login'&& !store.state.isLogin) next({name:'Login'})
//   else next()
// })

export default router;